package com.lottery.im.module.result.presenter;

import android.app.Activity;
import com.lottery.im.api.ApiClient;
import com.lottery.im.api.observer.BaseListObserver;
import com.lottery.im.base.BaseFragmentPresenter;
import com.lottery.im.module.result.view.DoubleStatisticsView;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.FragmentEvent;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class DoubleStatisticsPresenter extends BaseFragmentPresenter<DoubleStatisticsView> {

  public DoubleStatisticsPresenter(Activity activity, DoubleStatisticsView iView,
      LifecycleProvider<FragmentEvent> provider) {
    super(activity, iView, provider);
  }

  /*
   * 查询双面统计-预测
   * */
  public void queryDXDSLost(String gameType, String type) {
    ApiClient.getApiRetrofitInstance()
        .queryDXDSLost(gameType, type)
        .throttleFirst(2, TimeUnit.SECONDS)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .compose(provider.bindToLifecycle())
        .subscribe(new BaseListObserver<String>() {
                     @Override public void onStart() {
                     }

                     @Override public void onSuccess(List<String> list) {
                       iView.queryDxDsSuccess(list);
                     }

                     @Override public void onFail(String code, String msg) {
                     }

                     @Override public void onException(String msg) {
                     }

                     @Override public void onFinish() {
                     }
                   }
        );
  }
}
